/**
 * This panel is the panel that appears on the left side of the frame,
 * it should contain methods to change the user roles and the current user.
 * 
 * @author Nathan Judkins
 */

package GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.util.List;
import java.util.ArrayList;

import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import FileIO.FileManager;
import Listeners.AccessConferenceListener;
import Listeners.LoginListener;
import Model.*;
import Model.Conference.Role;



@SuppressWarnings("serial")
public class CurrentUserPanel extends JPanel
{
  private ConferenceWizardFrame my_frame;
  private Conference my_current_conference;
  private User my_current_user;
  private ConferenceManager my_manager;
  
  public CurrentUserPanel(ConferenceWizardFrame the_frame, User the_current_user, Conference the_current_conference,
      final ConferenceManager the_manager)
  {
    super();
    my_frame = the_frame;
    my_current_user = the_current_user;
    my_current_conference = the_current_conference;
    my_manager = the_manager;
    
    createUserPanel();
      
  }
  
  public void createUserPanel()
  {
    
    //JPanel userInfo = new JPanel();
    
    BoxLayout boxxy = new BoxLayout(this, BoxLayout.Y_AXIS);
    
    setLayout(boxxy);
    setMinimumSize(new Dimension(250, 600));
    setBackground(Color.LIGHT_GRAY);
    
    JLabel currentUser = new JLabel("User: " + my_current_user.userName());

    //JLabel currentRole = new JLabel("Role: " + r.toString());
    
    add(currentUser);
    //userInfo.add(currentRole);
    
    add(new JLabel(my_current_conference.conferenceName()));
    
    JButton changeRole = new JButton("Change Current Role");
    changeRole.addActionListener(new AccessConferenceListener(my_current_conference, 
        my_manager, my_frame));
    
    add(changeRole);
    
    JButton logOut = new JButton("Log Out");
    logOut.addActionListener(new AbstractAction() {
      
      public void actionPerformed(ActionEvent e)
      {
          FileManager.saveConferences(my_manager.getConferences());
          FileManager.saveUsers(my_manager.getUsers());
          
          my_frame.dispose();
          ConferenceWizardFrame blarg = new ConferenceWizardFrame();
      }
  });
    
    add(logOut);
    
    //my_frame.add(userInfo, BorderLayout.WEST);
    my_frame.pack();
    setVisible(true);

    
  }
  
}
